package models;

import models.enums.StockSourceBizType;
import product.ProductSpec;

import javax.persistence.*;
import java.util.Date;


/**
 * Created by liming on 16/7/16.
 * 库存中心变动历史记录
 */
@Entity
@Table(name = "admin_stock_history")
public class AdminStockHistory extends BaseModel {

    /**
     * 源头业务类型:
     * 库存初始化 STOCK_INIT
     * 库存盘点 STOCK_TAKING
     * 采购入库 STOCK_IN
     * 采购退货出库 STOCK_IN_RETURN
     * 销售出库 STOCK_OUT
     * 销售退货入库 STOCK_OUT_RETURN
     */
    @Column(name = "source_biz_type")
    @Enumerated(EnumType.STRING)
    public StockSourceBizType sourceBizType;

    /**
     * 源头主业务id
     */
    @Column(name = "source_biz_id")
    public Long sourceBizId;

    /**
     * 源头业务编号
     */
    @Column(name = "source_biz_code")
    public String sourceBizCode;

    /**
     * 源头子业务id
     */
    @Column(name = "source_biz_item_id")
    public Integer sourceBizItemId;

    /**
     * 仓库
     */
    @ManyToOne
    @JoinColumn(name = "admin_warehouse_id")
    public AdminWarehouse adminWarehouse;

    /**
     * 规格产品
     */
    @ManyToOne
    @JoinColumn(name = "product_spec_id")
    public ProductSpec productSpec;

    /**
     * 本次操作数量
     */
    @Column(name = "opt_num")
    public Double optNum;

    /**
     * 成本单价
     */
    @Column(name = "cost_price")
    public Double costPrice;

    /**
     * 成本金额
     */
    @Column(name = "cost_amount")
    public Double costAmount;

    /**
     * 变动前成本单价
     */
    @Column(name = "former_cost_price")
    public Double formerCostPrice;

    /**
     * 当时库存数量
     */
    @Column(name = "snap_stock_num")
    public Double snapStockNum;

    /**
     * 当时库存金额
     */
    @Column(name = "snap_stock_amount")
    public Double snapStockAmount;


}
